package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.tangyh.basic.annotation.log.WebLog;
import top.tangyh.basic.base.R;
import top.tangyh.basic.interfaces.echo.EchoService;
import top.tangyh.basic.base.controller.SuperController;
import top.tangyh.lamp.care.service.BHl7GmService;
import top.tangyh.lamp.care.entity.BHl7Gm;
import top.tangyh.lamp.care.vo.query.DeleteBactchQuery;
import top.tangyh.lamp.care.vo.query.DeleteQuery;
import top.tangyh.lamp.care.vo.result.GmOutVO;
import top.tangyh.lamp.care.vo.result.MoveInfoOutVO;
import top.tangyh.lamp.care.vo.save.BHl7GmSaveVO;
import top.tangyh.lamp.care.vo.save.GmInfoInVO;
import top.tangyh.lamp.care.vo.update.BHl7GmUpdateVO;
import top.tangyh.lamp.care.vo.result.BHl7GmResultVO;
import top.tangyh.lamp.care.vo.query.BHl7GmPageQuery;

import java.util.List;

import static top.tangyh.basic.base.R.success;
import static top.tangyh.lamp.common.constant.SwaggerConstants.DATA_TYPE_STRING;

/**
 * <p>
 * 前端控制器
 * 过敏史
 * </p>
 *
 * @author zqb
 * @date 2024-07-15 11:24:55
 * @create [2024-07-15 11:24:55] [zqb] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/gm")
@Tag(name = "HL7:过敏史")
public class BHl7GmController {
//    extends SuperController<BHl7GmService, Long, BHl7Gm
//            , BHl7GmSaveVO, BHl7GmUpdateVO, BHl7GmPageQuery, BHl7GmResultVO>
//    private final EchoService echoService;
//    @Override
//    public EchoService getEchoService() {
//        return echoService;
//    }

    @Parameters({
            @Parameter(name = "hospitalNumber", description = "住院号", schema = @Schema(type = DATA_TYPE_STRING), in = ParameterIn.QUERY),
    })
    @Operation(summary = "查询患者的过敏记录列表")
    @GetMapping("/list")
    @WebLog(value = "查询患者的过敏记录列表")
    public R<List<GmOutVO>> listOperaInfo(@RequestParam String hospitalNumber) {
        return success(hl7GmService.listGmOutVO(hospitalNumber));
    }


    private final BHl7GmService hl7GmService;

    @Operation(summary = "添加过敏")
    @PostMapping
    public R add(@RequestBody GmInfoInVO infoInVO) {
        hl7GmService.addGmInfo(infoInVO);
        return R.success();
    }

    @Operation(summary = "修改过敏")
    @PutMapping
    public R update(@RequestBody GmInfoInVO infoInVO) {
        hl7GmService.updateGmInfo(infoInVO);
        return R.success();
    }

    @Operation(summary = "删除过敏")
    @DeleteMapping
    public R delete(@RequestBody DeleteQuery deleteQuery) {
        hl7GmService.deleteGmInfo(deleteQuery.getId());
        return R.success();
    }


}


